package com.xxx.meter.ui.submit;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xxx.meter.R;
import com.xxx.meter.model.http.bean.SubmitBean;

import java.util.ArrayList;
import java.util.List;

public class SubmitAdapter extends BaseQuickAdapter<SubmitBean, BaseViewHolder> {

    private List<SubmitBean> mCheckList;

    public void setCheckData(List<SubmitBean> checkData) {
        this.mCheckList.clear();
        this.mCheckList.addAll(checkData);
        notifyDataSetChanged();
    }

    SubmitAdapter(@Nullable List<SubmitBean> data) {
        super(R.layout.item_submit, data);
        mCheckList = new ArrayList<>();
    }

    @Override
    protected void convert(BaseViewHolder helper, SubmitBean item) {
        helper.setText(R.id.item_submit_name, item.getName() + "  " + item.getTime());

        View view = helper.getView(R.id.item_submit_tag);
        boolean b = false;
        for (int i = 0; i < mCheckList.size(); i++) {
            SubmitBean submitBean = mCheckList.get(i);
            if (submitBean.getName().equals(item.getName())){
                b = true;
                break;
            }
        }
        if (b) {
            view.setVisibility(View.VISIBLE);
        } else {
            view.setVisibility(View.GONE);
        }
    }
}
